package com.yanfan.njLighting.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.njLighting.mapper.NjLightingDeviceMapper;
import com.yanfan.njLighting.domain.NjLightingDevice;
import com.yanfan.njLighting.service.INjLightingDeviceService;

/**
 * 智能照明设备Service业务层处理
 *
 * @author genluo
 * @date 2024-10-30
 */
@Service
public class NjLightingDeviceServiceImpl extends ServiceImpl<NjLightingDeviceMapper, NjLightingDevice> implements INjLightingDeviceService {
    @Autowired
    private NjLightingDeviceMapper njLightingDeviceMapper;


    /**
     * 查询智能照明设备列表
     *
     * @param njLightingDevice 智能照明设备
     * @return 智能照明设备
     */
    @Override
    public List<NjLightingDevice> queryPageList(NjLightingDevice njLightingDevice) {
        LambdaQueryWrapper<NjLightingDevice> lqw = buildQueryWrapper(njLightingDevice);
        return njLightingDeviceMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return njLightingDeviceMapper.queryPageList(njLightingDevice);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<NjLightingDevice> buildQueryWrapper(NjLightingDevice bo) {
        LambdaQueryWrapper<NjLightingDevice> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getDeviceType()), NjLightingDevice::getDeviceType, bo.getDeviceType());
        lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), NjLightingDevice::getDeviceName, bo.getDeviceName());
        lqw.like(StringUtils.isNotBlank(bo.getPosition()), NjLightingDevice::getPosition, bo.getPosition());
        return lqw;
    }



}
